package com.guigu.service.impl.design;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.mapper.design.DLevelThirdMapper;
import com.guigu.pojo.design.DFile;
import com.guigu.pojo.design.DLevelFirst;
import com.guigu.pojo.design.DLevelSecond;
import com.guigu.pojo.design.DLevelThird;
import com.guigu.service.design.DLevelThirdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-17
 */
@Service
public class DLevelThirdServiceImpl extends ServiceImpl<DLevelThirdMapper, DLevelThird> implements DLevelThirdService {

    @Autowired
    private DLevelThirdMapper dLevelThirdMapper;

    @Override
    public ArrayList<DLevelThird> selectLevelThirdBySecondId(String secondId) {
        QueryWrapper<DLevelThird> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("PARENT_ID", secondId);
        ArrayList<DLevelThird> dLevelThirds = (ArrayList<DLevelThird>) dLevelThirdMapper.selectList(queryWrapper);
        return dLevelThirds;
    }

    @Override
    public ArrayList<DLevelThird> selectLevelThird() {
        ArrayList<DLevelThird> dLevelThirds = (ArrayList<DLevelThird>) dLevelThirdMapper.showDLevelThird();
        return dLevelThirds;
    }

    @Override
    public Boolean insertThird(DLevelThird third) {
        int rows = dLevelThirdMapper.insert(third);
        return rows > 0;
    }

    @Override
    public DLevelThird selectDLevelThirdOrderByDescOne() {
        QueryWrapper<DLevelThird> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("THIRD_ID");
        queryWrapper.last("limit 1");
        DLevelThird dLevelThird = dLevelThirdMapper.selectOne(queryWrapper);
        return dLevelThird;
    }

}
